import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class FractionallySizedBoxDemo extends StatelessWidget{
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('FractionallySizedBox'),
        centerTitle: true,
      ),
      body: Column(
        mainAxisAlignment: MainAxisAlignment.start,
        crossAxisAlignment: CrossAxisAlignment.start,
        children: <Widget>[
          Container(
            color: Colors.blue,
            height: 50,
            child: FractionallySizedBox(
              //对齐方式
              alignment: Alignment.center,
              //宽度因子 1为沾满整行
              widthFactor: 0.5,
              //高度因子
              heightFactor: 1,
              child: Text('123'),
            ),
          ),
          Padding(padding: EdgeInsets.all(20)),
          Container(
            color: Colors.yellow,
            height: 50,
            child: FractionallySizedBox(
              //对齐方式
              alignment: Alignment.center,
              //宽度因子 1为沾满整行
              widthFactor: 1,
              //高度因子
              heightFactor: 1,
              child: Text('123'),
            ),
          ),
        ],
      )
    );
  }

}